package com.edu.marker.dao;


import com.edu.marker.dao.DataCenter.Questions;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	
	private static final String DATABASE_NAME = "papers.db";
	private static final int DATABASE_VERSION = 1;
	
	static interface Tables {
        String QUESTIONS = "questions";
    }
	 
    public DBHelper(final Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " + Tables.QUESTIONS + " ("
                + Questions._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
                + Questions.QUESTION_ID + " TEXT NOT NULL,"
                + Questions.QUESTION_TITLE + " TEXT NOT NULL,"
                + Questions.QUESTION_BODY + " TEXT,"
                + Questions.QUESTION_TIME + " TEXT,"
                + Questions.QUESTION_SAVE + " TEXT DEFAULT '0',"
                + Questions.QUESTION_READ + " TEXT DEFAULT '0',"
                + "UNIQUE (" + Questions.QUESTION_ID + ") ON CONFLICT REPLACE)");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		 db.execSQL("DROP TABLE IF EXISTS " + Tables.QUESTIONS);
         onCreate(db);
	}
}
